/*
 * Copyright (c) 2021 Huawei Device Co.,  Ltd.
 * Licensed under the Apache License,  Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,  software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,  either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SWANLINK_FINANCE_RECPTPRINTER_SERVICE_H
#define SWANLINK_FINANCE_RECPTPRINTER_SERVICE_H
#include <system_ability.h>
#include <iremote_object.h>
#include <vector>
#include <string>
#include "irecptprinter_srv.h"
#include "recptprinter_srv_stub.h"
#include "sp_singleton.h"

namespace SwanLink {
namespace Finance {

class RecptprinterService final : public SystemAbility,
    public RecptprinterSrvStub {
DECLARE_SYSTEM_ABILITY(RecptprinterService)

DECLARE_DELAYED_SP_SINGLETON(RecptprinterService);
 public:
    void OnDump() override;
    void OnStart() override;
    void OnStop() override;

    int32_t Dump(int fd, const std::vector<std::u16string> &args) override;
    /**
     * 获取打印格式
     */
    int GetPrintFormat(int handle, PrintFormatType ftt) override;
    /**
     * 设置打印格式
     */
    void SetPrintFormat(int handle, PrintFormatType ftt, int value) override;
    /**
     * 获取设备配置
     */
    void GetDeviceSpec(int handle, DeviceSpec &spec) override;
    /**
     * 走纸
     */
    int FeedPaper(int handle, int line) override;
    /**
     * 切纸
     */
    int CutPaper(int handle, int line, int mode) override;
    /**
     * 添加文本
     */
    int AddText(int handle, int x, int y, const std::string& text) override;
    /**
     * 添加图片
     */
    int AddBitmap(int handle, int x, int y, const std::string& lpath) override;
    /**
     * 添加二维码
     */
    int AddQRCode(int handle, int x, int y, int w, const std::string& qr) override;
    /**
     * 添加条码
     */
    int AddBarCode(int handle, int x, int y, BarCodeSpec &spec, const std::string& bar) override;
    /**
     * 开始打印
     */
    void StartPrint(int handle, int timeout, PrintListener *listener) override;

 private:
    bool Init();
    bool ready_;
};
}  // namespace Finance
}  // namespace SwanLink

#endif  // SWANLINK_FINANCE_RECPTPRINTER_SERVICE_H
